package com.zyz.I_多线程.创建方式.Callable;

import java.util.concurrent.Callable;

/**
 * @author: vick
 * @Date: 2025/3/21
 * @Description:
 * @version: 1.0
 */

//1. 创建一个实现Callable的实现类
public class TestCallable implements Callable<Integer> {
    //2. 重写call方法，将需要执行的操作写在 call() 方法中
    @Override
    public Integer call() throws Exception {
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            if (i%2 == 0) {
                System.out.println(i);
                sum += i;
            }
        }
        return sum;
    }
}
